package com.cy.dda.comm.handler;

import java.io.IOException;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cy.dda.comm.exception.MsgException;
import com.cy.dda.model.Result;

/**
 * 错误异常 handler
 *
 * @author: tanyilin
 * @create: 2018年10月26日 下午3:19:11
 */
@ControllerAdvice
public class CommExceptionHandler {

	@ExceptionHandler(MsgException.class)
	@ResponseBody
	public Result handler(MsgException msgException) throws IOException {
		
		return Result.fail(msgException.getMessage(), msgException.getCode(), msgException.getValue());
	}
}
